import request from '@/utils/request'

export function login(data) {
  return request({
    url: '/user/login',
    method: 'POST',
    data
  })
}

export function register(data) {
  return request({
    url: '/user/register',
    method: 'POST',
    data
  })
}

export function deleteUser(uid) {
  return request({
    url: `/user/delete/${uid}`,
    method: 'DELETE'
  })
}

export function logout(data) {
  return request({
    url: '/user/logout',
    method: 'POST',
    data
  })
}

export function getInfo() {
  return request({
    url: '/user/info',
    method: 'get'
  })
}

export function getUserList(limit, page, params) {
  return request({
    url: `user/list/${limit}/${page}`,
    method: 'get',
    params
  })
}

export function postAvatar(data) {
  return request({
    url: `user/avatar`,
    method: 'POST',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

export function changePassword(data) {
  return request({
    url: `user/reset`,
    method: 'POST',
    data
  })
}

export function getOverview(params) {
  return request({
    url: `user/overview`,
    method: 'GET',
    params
  })
}

export function updateSign(data) {
  return request({
    url: `user/sign`,
    method: 'POST',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    data
  })
}

export function changeOtherPwd(data) {
  return request({
    url: `user/reset`,
    method: 'POST',
    data
  })
}

export function findUser(limit, page, params) {
  return request({
    url: `user/find/${limit}/${page}`,
    method: 'GET',
    params
  })
}
